$(function(){
	
	$(".ifLogin").click(function(){
		// console.log("点击哦了");
		if(localStorage.getItem("$loginUser") != null){
		//		console.log("存在");
			//console.log($(this).attr("id"));
			//$('.ifLogin>span').trigger('click') ;
		}else{
		//			console.log("不存在");
			this.href = "#";
			mui.alert("请先登陆");
		}
	});
	
	
	
	//点击购物车，判断有没有登陆，没有则跳转到登陆页
	$("#gotoShoppingCar").click(function(){
		if(localStorage.getItem("$loginUser") == null){
			window.location.href = "login.html"
		}else{
			window.location.href = "new-shopping-card.html"
		}
	});
	
	//设置用户名和用户头像
	if(localStorage.getItem("$loginUser") !=  null){
		// console.log("jkjkl");
		var users = JSON.parse(localStorage.getItem('$loginUser'));
		//	console.log(users.account)
		$("#account").text("");
		$("#account").text(users.account);
		$("#user_photo").attr('src',users.avatar);
	}
	
	//退出登陆
	$("#loginout").click(function(){
		if(localStorage.getItem("$loginUser") !=  null){
			localStorage.removeItem("$loginUser");
			mui.alert("退出成功")
		//	window.setTimeout(function(){
			window.location.href = "new-mine.html";
		//	},1000);
		}else{
			mui.alert("你还未登陆，请先登陆")
		}
		
		
	});
	
	
	$("#unfinished").click(function(){
		let data = JSON.parse(localStorage.getItem('$appData'));
		let goodsItem = AppData.getUnfinishedGoods(data.data,JSON.parse(localStorage.getItem("$loginUser")).account)
		localStorage.setItem("$unfinished",JSON.stringify(goodsItem));
		window.location.href = "new-mine-order.html";
	});
	
	$("#finished").click(function(){
		let data = JSON.parse(localStorage.getItem('$appData'));
		let goodsItem = AppData.getFinishedGoods(data.data,JSON.parse(localStorage.getItem("$loginUser")).account)
		localStorage.setItem("$finishedBuy",JSON.stringify(goodsItem));
		window.location.href = "new-mine-order1.html";
	});
	
	$("#comment").click(function(){
		let data = JSON.parse(localStorage.getItem('$appData'));
		let goodsItem = AppData.getCommentGoods(data.data,JSON.parse(localStorage.getItem("$loginUser")).account)
		localStorage.setItem("$commentBuy",JSON.stringify(goodsItem));
		window.location.href = "new-mine-order2.html";
	});
	
	$("#onSell").click(function(){
		let data = JSON.parse(localStorage.getItem('$appData'));
		let goodsItem = AppData.getOnSell(data.data,JSON.parse(localStorage.getItem("$loginUser")).account)
		localStorage.setItem("$onSell",JSON.stringify(goodsItem));
		window.location.href = "new-publish.html";
	});
	
	$("#finishgoodsSell").click(function(){
		let data = JSON.parse(localStorage.getItem('$appData'));
		let goodsItem = AppData.getFinishedGoodsSell(data.data,JSON.parse(localStorage.getItem("$loginUser")).account)
		localStorage.setItem("$finishSell",JSON.stringify(goodsItem));
		window.location.href = "new-mine-order4.html";
	});
	
	$("#commentgoodsSell").click(function(){
		let data = JSON.parse(localStorage.getItem('$appData'));
		let goodsItem = AppData.getCommentGoodsSell(data.data,JSON.parse(localStorage.getItem("$loginUser")).account)
		localStorage.setItem("$commentSell",JSON.stringify(goodsItem));
		window.location.href = "new-mine-order2.html";
	});
	
	
	
});
